package model

import (
	"fmt"
)

/*******************************************************************************
Copyright:cloud
Author:cloudapex@126.com
Version:1.0
Date:2020-07-09
Description: 公共数据
*******************************************************************************/

/*------------------------------------------------------------------------------
======================================常量=======================================
------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------
======================================类型=======================================
------------------------------------------------------------------------------*/

// => 菜单类型
type EPower int //
const (
	EPower_Menu EPower = iota + 1 // 菜单
	EPower_Func                   // 功能
	EPower_Data                   // 数据
	EPower_Max
) //
func (e EPower) String() string {
	switch e {
	case EPower_Menu:
		return "菜单"
	case EPower_Func:
		return "功能"
	case EPower_Data:
		return "数据"
	}
	return fmt.Sprintf("EPower_unknow(%d)", e)
}

// => 树节点类型
type ETreeNode int //
const (
	ETreeNode_Base ETreeNode = iota + 1 // 子节点
	ETreeNode_Leaf                      // 叶节点
	ETreeNode_Max
) //
func (e ETreeNode) String() string {
	switch e {
	case ETreeNode_Base:
		return "子节点"
	case ETreeNode_Leaf:
		return "叶节点"
	}
	return fmt.Sprintf("ETreeNode_unknow(%d)", e)
}

/*------------------------------------------------------------------------------
======================================结构=======================================
------------------------------------------------------------------------------*/
// => 菜单种类
type RoleKind struct {
	Kind int32  `json:"kind"`
	Name string `json:"name"`
}

var RoleKinds = []RoleKind{{1, "营销招生"}, {2, "营销班主任"}, {3, "教学"}, {4, "行政"}, {5, "推广"}, {6, "财务"}, {7, "技术"}, {8, "管理员"}}

func RoleName(kind int32) string {
	for _, it := range RoleKinds {
		if it.Kind == kind {
			return it.Name
		}
	}
	return ""
}

/*------------------------------------------------------------------------------
======================================方法=======================================
------------------------------------------------------------------------------*/

// 组合节点路径
func NodePath(parentPath string, parentId int64) string {
	if parentId == 0 {
		return "0"
	}
	return fmt.Sprintf("%s/%d", parentPath, parentId)
}
